#ifndef _PARTHUS_SYS_TYPES_
#define _PARTHUS_SYS_TYPES_

/******************************************************************************
 * MODULE NAME:    sys_types.h
 * PROJECT CODE:    BlueStream
 * DESCRIPTION:    All System Wide Type Definitions
 * MAINTAINER:     John Nelson, Gary Fleming, Conor Morris
 * DATE:           1 May 1999
 *
 * SOURCE CONTROL: $Id: sys_types.h,v 1.10 2009/02/11 05:58:22 tianwq Exp $
 *
 * LICENSE:
 *     This source code is copyright (c) 1999-2004 Ceva Inc.
 *     All rights reserved.f
 *
 * REVISION HISTORY:
 *    01 May 1999  -    jn      - Initial version 0.8
 *    01 June 1999 -    jn      - Update to V0.9
 *    22 July 1999 -    gf      - Updated to support higher layers (error code,
 *                                event structure, srMode, spMode,
 *    08 Mar 2001  -    js      - Moved intrinsic type use to hal_sys_types.h
 *                                for portability
 *
 * NOTES TO USERS:
 *    Little endian format used, i.e. least significant byte in lowest address
 ******************************************************************************/

/*
 * The following include file should be provided by any ANSI C compiler
 * and compiler definitions such as size_t etc.
 */

#include <stddef.h>

/*
 * Basic system types such as u_int8, u_int16 etc. are found in the following
 * platform specific file.
 */
#include "sys_hal_types.h"
#include "sys_const.h"

#define FALSE 0
#ifndef TRUE
#define TRUE  (!FALSE)
#endif

typedef u_int8 boolean;

/*
 * Baseband originated types
 */
typedef t_u_int64 t_syncword;        /* Sync word                          */
typedef u_int32   t_uap_lap;         /* Uap [31:24], Lap [23:0             */

typedef enum
{
   TX_START     = 0,       /* Corresponds to Interrupt Tim0 */
   TX_MID       = 1,       /* Corresponds to Interrupt Tim1 */
   RX_START     = 2,       /* Corresponds to Interrupt Tim2 */
   RX_MID       = 3,       /* Corresponds to Interrupt Tim3 */
   NO_FRAME_POS = 5        /* No valid frame position */
} t_frame_pos;             /* The Tx/Rx positions in a 2-slot frame */


typedef u_int8  t_freq;        /* frequency type */
typedef u_int8  t_uap;         /* upper address part type */
typedef u_int32 t_lap;         /* lower address part type */
typedef u_int16 t_nap;         /* non-significant address part type */
typedef u_int32 t_clock;       /* clock type */
typedef u_int16 t_status;      /* status type */
typedef u_int8  t_am_addr;     /* AM address type */
typedef u_int8  t_lt_addr;     /* LT address type */

typedef u_int8  t_deviceIndex;          /* index to a device */
typedef u_int8  t_piconet_index;        /* index to piconet */
typedef u_int8* t_p_pdu;                /* pointer to a PDU */
typedef u_int16 t_connectionHandle;     /* connection handle */

#ifndef PRH_COMBINED_STACK_COMMON_TYPES
#define PRH_COMBINED_STACK_COMMON_TYPES 1
typedef u_int32 t_classDevice;          /* class of device */
#endif

typedef u_int8  t_sco_cfg;     /* sco codec configuration */
typedef u_int8  t_sco_fifo;    /* sco fifo */

/*
 * BD Address Type and associated operations
 */
typedef struct
{
   /*
    * u_int8 lap_byte0, lap_byte1, lap_byte2, uap, nap_byte0, nap_byte 1
    */
   u_int8 bytes[6];
} t_bd_addr;

#define BDADDR_Get_LAP(p_bd_addr)                                       \
            ( ((t_lap) (p_bd_addr)->bytes[2] << 16) +                   \
            (  (t_lap) (p_bd_addr)->bytes[1] << 8) + (p_bd_addr)->bytes[0] )

#define BDADDR_Get_UAP(p_bd_addr)                                       \
            ( (t_uap) (p_bd_addr)->bytes[3] )

#define BDADDR_Get_NAP(p_bd_addr)                                       \
            ( (t_nap) (((t_nap) (p_bd_addr)->bytes[5] << 8) +           \
              (p_bd_addr)->bytes[4]))

#define BDADDR_Get_UAP_LAP(p_bd_addr)                                   \
             ( (t_uap_lap) BDADDR_Get_UAP(p_bd_addr)<<24 |              \
               (t_uap_lap) BDADDR_Get_LAP(p_bd_addr) )

#define BDADDR_Get_Byte_Array_Ex(p_bd_addr, p_byte_array)               \
             { const u_int8 *p_bda = (p_bd_addr)->bytes;                \
               u_int8 *p_byte = p_byte_array;                           \
               *p_byte++ = *p_bda++;                                    \
               *p_byte++ = *p_bda++;                                    \
               *p_byte++ = *p_bda++;                                    \
               *p_byte++ = *p_bda++;                                    \
               *p_byte++ = *p_bda++;                                    \
               *p_byte   = *p_bda;                                      \
             }

#define BDADDR_Get_Byte_Array_Ref(p_bd_addr)                            \
            ( (p_bd_addr)->bytes )

#define BDADDR_Set_LAP(p_bd_addr, LAP)                                  \
            {  t_lap lap = (LAP);                                       \
               (p_bd_addr)->bytes[0] = (u_int8)(lap & 0xFF);            \
               (p_bd_addr)->bytes[1] = (u_int8)((lap>>8) & 0xFF);       \
               (p_bd_addr)->bytes[2] = (u_int8) (lap>>16); }

#define BDADDR_Set_UAP(p_bd_addr, UAP)                                  \
            ((p_bd_addr)->bytes[3] = (UAP))

#define BDADDR_Set_NAP(p_bd_addr, NAP)                                  \
            {  t_nap nap = (NAP);                                       \
               (p_bd_addr)->bytes[4] = (u_int8) (nap & 0xFF);           \
               (p_bd_addr)->bytes[5] = (u_int8) (nap>>8); }

#define BDADDR_Assign_from_Byte_Array(p_bd_addr, p_byte_array)          \
            {  u_int8 *p_bda = (p_bd_addr)->bytes;                      \
               const u_int8 *p_byte = (p_byte_array);                   \
               *p_bda++ = *p_byte++;                                    \
               *p_bda++ = *p_byte++;                                    \
               *p_bda++ = *p_byte++;                                    \
               *p_bda++ = *p_byte++;                                    \
               *p_bda++ = *p_byte++;                                    \
               *p_bda   = *p_byte;                                      \
            }

#define BDADDR_Set_to_Zero(p_bd_addr)                                   \
            {  u_int8 *p_bda = (p_bd_addr)->bytes;                      \
               u_int8 *p_bda_end = (p_bd_addr)->bytes+6;                \
               while (p_bda < p_bda_end) { *p_bda++ = 0; }              \
            }

#define BDADDR_Set_LAP_UAP_NAP(p_bd_addr, lap, uap, nap)                \
            {  BDADDR_Set_LAP(p_bd_addr, lap);                          \
               BDADDR_Set_UAP(p_bd_addr, uap);                          \
               BDADDR_Set_NAP(p_bd_addr, nap); }

#define BDADDR_Copy(p_bd_addr_dest, p_bd_addr_src)                      \
            ( *p_bd_addr_dest = *p_bd_addr_src )

#define BDADDR_Is_Equal(p_bd_addr_1, p_bd_addr_2)                       \
       ((BDADDR_Get_LAP(p_bd_addr_1) == BDADDR_Get_LAP(p_bd_addr_2)) && \
        (BDADDR_Get_UAP(p_bd_addr_1) == BDADDR_Get_UAP(p_bd_addr_2)) && \
        (BDADDR_Get_NAP(p_bd_addr_1) == BDADDR_Get_NAP(p_bd_addr_2)) )

#define BDADDR_Convert_to_U32x2(p_bd_addr, p_u32_words)                 \
        {  p_u32_words[0] = BDADDR_Get_UAP_LAP(p_bd_addr);              \
           p_u32_words[1] = BDADDR_Get_NAP(p_bd_addr);  }


typedef enum
{
    LCH_null        = 0,
    LCH_continue    = 1,
    LCH_start       = 2,
    LMP_msg         = 3
}  t_LCHmessage;

typedef enum
{
    MASTER          = 0,
    SLAVE           = 1
} t_role;


typedef u_int8  t_piconetIndex;  /* an index into a piconet */
typedef u_int16 t_length;        /* maximum data packet length type */

/*
 * Note LM Air Mode is distinct from HCI Voice Settings
 */
typedef enum {
    LM_AIR_MODE_U_LAW,
    LM_AIR_MODE_A_LAW,
    LM_AIR_MODE_CVSD,
    LM_AIR_MODE_TRANSPARENT
} t_lm_air_mode;


typedef t_clock t_timer;         /* timer type */
typedef t_clock t_slots;         /* slots type */

/*
 * Define the packet types
 *
 * t_packet         represents a single packet type e.g. DM1
 * t_packetTypes    represents a bit field representation of
 *                  packets DM1_BIT|DM3_BIT
 */
typedef enum
{
    NULLpkt     =  0x00,   /* a NULL packet */
    POLLpkt     =  0x01,   /* a POLL packet */
    FHSpkt      =  0x02,   /* an FHS packet */
    DM1         =  0x03,   /* a DM1 packet */
    DH1         =  0x04,   /* a DH1 packet */
    HV1         =  0x05,   /* a HV1 packet */
    HV2         =  0x06,   /* a HV2 packet */
    HV3         =  0x07,   /* a HV3 packet */
    DV          =  0x08,   /* a DV packet */
    AUX1        =  0x09,   /* an AUX1 packet */
    DM3         =  0x0A,   /* a DM3 packet */
    DH3         =  0x0B,   /* a DH3 packet */
    EV4         =  0x0C,   /* an EV4 packet */
    EV5         =  0x0D,   /* an EV5 packet */
    DM5         =  0x0E,   /* a DM5 packet */
    DH5         =  0x0F,   /* a DH5 packet */
    IDpkt       =  0x10,   /* an ID packet */
    INVALIDpkt  =  0x11,   /* an unexpected packet type */
    EV3         =  0x17,   /* an EV3 packet. N.B. EV3 packet shares 7 with HV3. Moved
                                    to 7 | 0b10000. Ensure top bit is sheared off before
                                    exporting outside controller to either host or peer! */
    _2DH1       =  0x24,   /* EDR ACL 2DH1 packet   b3-b0 same as DH1*/
    _3DH1       =  0x28,   /* EDR ACL 3DH1 packet   b3-b0 same as DV  */
    _2DH3       =  0x2A,   /* EDR ACL 2DH3 packet   b3-b0 same as DM3*/
    _3DH3       =  0x2B,   /* EDR ACL 3DH3 packet   b3-b0 same as DH3*/
    _2DH5       =  0x2E,   /* EDR ACL 2DH5 packet   b3-b0 same as DM5*/
    _3DH5       =  0x2F,   /* EDR ACL 3DH5 packet   b3-b0 same as DH5*/
    _2EV3       =  0x26,   /* EDR ESCO 2EV3 packet   b3-b0 same as HV2 */
    _3EV3       =  0x27,   /* EDR ESCO 3EV3 packet   b3-b0 same as HV3,EV3 */
    _2EV5       =  0x2C,   /* EDR ESCO 2EV5 packet   b3-b0 same as EV4 */
    _3EV5       =  0x2D    /* EDR ESCO 3EV5 packet   b3-b0 same as EV5 */
} t_packet;

/*
 * Create type to support bit combination of supported packet types
 */

#define NULL_BIT_MASK      0x0001
#define POLL_BIT_MASK      0x0002
#define FHS_BIT_MASK       0x0004
#define DM1_BIT_MASK       0x0008

#define DH1_BIT_MASK       0x0010
#define HV1_BIT_MASK       0x0020
#define HV2_BIT_MASK       0x0040
#define HV3_BIT_MASK       0x0080
#define EV3_BIT_MASK       0x0080

#define DV_BIT_MASK        0x0001   /* 20090106 tianwq modify: old value conflict with 2DH3, induce error in edr mode  */
#define AUX1_BIT_MASK      0x0200
#define DM3_BIT_MASK       0x0400
#define DH3_BIT_MASK       0x0800

#define EV4_BIT_MASK       0x1000
#define EV5_BIT_MASK       0x2000
#define DM5_BIT_MASK       0x4000
#define DH5_BIT_MASK       0x8000

#define _2DH1_BIT_MASK     0x0002
#define _3DH1_BIT_MASK     0x0004
#define _2DH3_BIT_MASK     0x0100
#define _3DH3_BIT_MASK     0x0200
#define _2DH5_BIT_MASK     0x1000
#define _3DH5_BIT_MASK     0x2000
#define _2EV3_BIT_MASK     0x0040
#define _3EV3_BIT_MASK     0x0080
#define _2EV5_BIT_MASK     0x0100
#define _3EV5_BIT_MASK     0x0200

typedef u_int16 t_packetTypes;   /* packet-types based up | of above */

typedef enum
{
    NAK=0,
    ACK=1
} t_arqn;

typedef enum
{
    STOP=0,
    GO=1
} t_flow;

typedef enum
{
    TX_READY                                =  0,       /* Ready to transmit */
    RX_READY                                =  1,       /* Ready to receive */
    TX_OK                                   =  2,       /* Transmission successful */
    TX_NONE                                 =  3,       /* No Transmission occurred */
    RX_OK                                   =  4,       /* Reception successful */
    RX_NONE                                 =  5,       /* No Reception active */
    RX_DUPLICATE                            =  6,       /* Received packet was interpreted as duplicate */
    RX_NO_PACKET                            =  7,       /* Received no packet */
    RX_RESTRICTED_PACKET                    =  8,       /* Received a restricted baseband packet */
    RX_AMADDR_ERROR                         =  9,       /* Incorrect AM address in received packet */
    RX_HEC_ERROR                            = 10,       /* HEC error in received packet */
    RX_CRC_ERROR                            = 11,       /* CRC error in received packet */
    TX_2_IDS_IN_SLOT                        = 12,       /* Indicates that 2_IDS were tx in this slot */
    TX_UNEXPECTED_ERROR                     = 13,       /* Unexpected PKA */
    RX_UNEXPECTED_ERROR                     = 14,       /* Unexpected PKD */
    RX_BROADCAST_PACKET                     = 15,       /* Rx ACL Broadcast Packet */
    RX_BROADCAST_DUPLICATE                  = 16,       /* Rx ACL Broadcast Duplicate, for L2CAP cont*/
    RX_NORMAL_HEADER                        = 17,       /* Rx ACL packet header */
    RX_BROADCAST_HEADER                     = 18,       /* Rx ACL Broadcast Packet Header */
    RX_MISSED_HEADER                        = 19,       /* Header For This Packet Not Processed */
    RX_NORMAL_HEADER_PRIMARY_LT_ADDR        = 20,
    RX_NORMAL_HEADER_SECONDARY_LT_ADDR      = 21
} t_TXRXstatus;                         /* Receive and Transmit Status Values */


typedef enum
{
     SCO_LINK       =0x00,         /* SCO Link */
     ACL_LINK       =0x01,         /* ACL Link */
     ESCO_LINK      =0x02          /* eSCO Link */
} t_linkType; /* link type */


enum e_error_codes
{
#ifndef NO_ERROR
    NO_ERROR                                = 0x00,     /* No Error */
#endif
    ILLEGAL_COMMAND                         = 0x01,     /* Illegal Command */
    NO_CONNECTION                           = 0x02,     /* No Connection   */
    HARDWARE_FAILURE                        = 0x03,     /* Hardware Failure */
    PAGE_TIMEOUT                            = 0x04,     /* Page Timeout Occurred */
    AUTHENTICATION_FAILURE                  = 0x05,     /* Authentication Failed */
    PIN_MISSING                             = 0x06,     /* PIN missing */
    MEMORY_FULL                             = 0x07,     /* Out of memory */
    CONNECTION_TIMEOUT                      = 0x08,     /* Connection timed out */
    MAX_NUM_CONNECTIONS                     = 0x09,     /* Maximum number of connections exceeded */
    MAX_NUM_SCO                             = 0x0A,     /* Maximum number of SCO connections exceeded */
    ACL_ALREADY_EXISTS                      = 0x0B,     /* Maximum number of ACL connections exceeded */
    COMMAND_DISALLOWED                      = 0x0C,     /* Command was disallowed */
    HOST_REJECT_LIMITED_RESOURCES           = 0x0D,     /* Host rejected, due to limited resources */
    HOST_REJECT_SECURITY                    = 0x0E,     /* Host rejected, due to security issues */
    HOST_REJECT_PERSONAL_DEVICE             = 0x0F,     /* Host rejected, personal device */
    CONNECTION_ACCEPT_TIMEOUT               = 0x10,     /* Host timed out */
    UNSUPPORTED_FEATURE                     = 0x11,     /* Stack does not support this feature */
    INVALID_HCI_PARAMETERS                  = 0x12,     /* Illegal HCI parameter(s) in request */
    REMOTE_USER_TERMINATED_CONNECTION       = 0x13,     /* Remote user terminated the connection */
    REMOTE_RESOURCES_TERMINATED_CONNECTION  = 0x14,     /* Remote rejected, limited resources */
    REMOTE_POWER_TERMINATED_CONNECTION      = 0x15,     /* Remote rejected, limited power */
    LOCAL_TERMINATED_CONNECTION             = 0x16,     /* local device terminated connection */
    REPEATED_ATTEMPTS                       = 0x17,     /* max number of repeated attempts exceeded */
    PAIRING_NOT_ALLOWED                     = 0x18,     /* pairing not allowed */
    UNKNOWN_LMP_PDU                         = 0x19,     /* unknown type of lmp pdu*/
    UNSUPPORTED_REMOTE_FEATURE              = 0x1A,     /* unsupported lmp feature */
    SCO_OFFSET_REJECTED                     = 0x1B,     /* rejected, sco offset unsuitable */
    SCO_INTERVAL_REJECTED                   = 0x1C,     /* rejected, sco interval unsuitable*/
    SCO_AIR_MODE_REJECTED                   = 0x1D,     /* rejected, sco air-mode unsuitable */
    INVALID_LMP_PARAMETERS                  = 0x1E,     /* invalid lmp parameters */
    UNSPECIFIED_ERROR                       = 0x1F,     /* unspecified error */
    UNSUPPORTED_PARAMETER_VALUE             = 0x20,     /* unsupported parameter value */
    ROLE_CHANGE_NOT_ALLOWED                 = 0x21,
    LMP_RESPONSE_TIMEOUT                    = 0x22,
    LMP_ERROR_TRANSACTION_COLLISION         = 0x23,     /* used by Master when both LMs initiate the same procedure simultaneously */
    LMP_PDU_NOT_ALLOWED                     = 0x24,
    ENCRYPTION_MODE_NOT_ACCEPTABLE          = 0x25,
    UNIT_KEY_USED                           = 0x26,
    QOS_NOT_SUPPORTED                       = 0x27,
    INSTANT_PASSED                          = 0x28,
    PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED     = 0x29,

    /*
     * V1.2 Error Codes
     */
    EC_DIFFERENT_TRANSACTION_COLLISION          = 0x2A,
    EC_INSUFFICIENT_RESOURCES_FOR_SCATTER_MODE_REQUEST = 0x2B,
    EC_QOS_UNACCEPTABLE_PARAMETER               = 0x2C,
    EC_QOS_REJECTED                             = 0x2D,
    EC_CHANNEL_CLASSIFICATION_NOT_SUPPORTED     = 0x2E,
    EC_INSUFFICIENT_SECURITY                    = 0X2F,
    EC_PARAMETER_OUT_OF_MANDATORY_RANGE         = 0X30,
    EC_SCATTER_MODE_NO_LONGER_REQUIRED          = 0x31,
    EC_ROLE_SWITCH_PENDING                      = 0x32,
    EC_SCATTER_MODE_PARAMETER_CHANGE_PENDING    = 0x33,
    EC_RESERVED_SLOT_VIOLATION                  = 0X34,
    EC_ROLE_SWITCH_FAILED                       = 0x35,

    /*
     * V2.1 Error Codes
     */
    EC_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE      = 0x36,
    EC_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST     = 0x37,
    EC_HOST_BUSY_PAIRING                        = 0x38,

    /*
     * Extensions, used for Parthus Abstract Test Suites
     * Values never used and hence relocatable!
     */
    PRTH_TEST_PASSED_DEVIATED,
    PRTH_TEST_FAILED,

    /*
     * Test results that don't result in failure
     */
    PRTH_TEST_IS_INCOMPLETE,
    PRTH_TEST_DUPLICATE,
    PRTH_TEST_REQUIRES_HARDWARE,
    PRTH_TEST_IS_OBSOLETE,
    PRTH_TEST_IS_AMBIGUOUS,
    PRTH_TEST_NOT_SUPPORTED,
    PRTH_TEST_NOT_DEFINED,
    PRTH_TEST_LMP_FEATURE_IS_SUPPORTED,
    PRTH_TEST_LMP_FEATURE_IS_NOT_SUPPORTED,
    PRTH_TEST_SYS_FEATURE_IS_SUPPORTED,
    PRTH_TEST_SYS_FEATURE_IS_NOT_SUPPORTED,
    PRTH_TEST_SKIPPED

};  /*  Error Messages used by the HC, LMP, L2CAP */


/*
 * Error Messages used by the HC, LMP, L2CAP and ATS Tests
 */
typedef enum e_error_codes t_error;

#define PRTH_TEST_PASSED NO_ERROR



/*
 * The following structure represents the definitions for LMP encrypt_mode
 * Note hardware encrypt register is 0 off, 1 p2p, 2 broadcast, 3 p2p+broadcast
 */
typedef enum
{
    ENCRYPT_NONE=0,                     /* No Encryption                     */
    ENCRYPT_POINT2POINT=1,              /* Non-Broadcast / P to P Encryption */
    ENCRYPT_POINT2POINT_BROADCAST=2,    /* Both Broadcast and PtoP Encrypted */
    ENCRYPT_HARDWARE_ONLY_ALL=3,        /* Remap of 2 for hardware           */
    ENCRYPT_MASTER_RX_ONLY=8+1,         /* Master Tx Unencrypt, Rx Encrypt   */
    ENCRYPT_MASTER_TX_ONLY=16+1         /* Master Tx Encrypt, Rx UnEncrypt   */

} t_encrypt_mode;                       /* Encryption Mode                   */

typedef struct t_hci_event
{
    t_bd_addr bd_addr;
    t_connectionHandle handle;
    t_error status;
    t_linkType linkType;
    t_encrypt_mode encrypt_mode;  /* Default Encryption Disabled */
    t_classDevice classDevice;
    t_error reason;
} t_hci_event;


typedef enum
{
    STANDARD_SCAN           = 0,
    INTERLACED_SCAN         = 1,
    CONTINUOUS_SCAN         = 2
} t_scan_type;


typedef struct t_scanActivity
{
    t_clock     interval; /* scan interval */
    t_clock     window;   /* scan activity window */
    t_scan_type scan_type; /*Interlaced/Non interlaced, One_shot/Continuous*/
}t_scanActivity;   /* scan activity type */


typedef enum
{
    R0          = 0,
    R1          = 1,
    R2          = 2
} t_pageScanRepit; /* page scan repetitions type */

typedef enum
{
    P0           = 0,
    P1           = 1,
    P2           = 2
} t_pageScanPeriod; /* page scan period type */

typedef enum
{
    MANDATORY_PAGE_SCAN     = 0,        /* Mandatory Page Scan Mode */
    OPTIONAL_PAGE_SCAN_1    = 1,        /* Type 1 Optional Page Scan Mode */
    OPTIONAL_PAGE_SCAN_2    = 2,        /* Type 2 Optional Page Scan Mode */
    OPTIONAL_PAGE_SCAN_3    = 3         /* Type 3 Optional Page Scan Mode */
} t_pageScanMode;                       /* Types of page scan modes */

typedef enum t_scanEnable
{
    NO_SCANS_ENABLED            = 0x00, /* No scanning enabled */
    INQUIRY_SCAN_ONLY_ENABLED   = 0x01, /* Only inquiry scan enabled */
    PAGE_SCAN_ONLY_ENABLED      = 0x02, /* Only page scan enabled */
    BOTH_SCANS_ENABLED          = 0x03  /* Both page scan and inquiry scan enabled */
} t_scanEnable;                         /* Scan Enable type */



typedef struct t_pageParams
{
    t_bd_addr       *p_bd_addr;         /* pointer to a bluetooth device address */
    t_packetTypes    packet_types;      /* Requested packet types */
    t_pageScanRepit  srMode ;           /* page scan repetition mode */
    t_pageScanMode   pageScanMode;      /* page scan mode */
    u_int8           allow_role_switch; /* True if role switch allowed */
    t_clock          clockOffset;       /* clock offset */
} t_pageParams;                         /* collection of paging parameters */


typedef struct t_inquiryResult
{
    t_bd_addr bd_addr;           /* bluetooth device address */
    t_pageScanRepit srMode;      /* page scan repetition mode */
    t_pageScanPeriod spMode;     /* page scan period mode */
    t_pageScanMode pageScanMode; /* page scan mode */
    t_classDevice Cod;           /* class of device */
    u_int16 clkOffset;           /* clock offset */
    s_int8 rssi;                 /* RSSI */
} t_inquiryResult;               /* container for an inquiry result */

/*
 * RF Hopping Selection Types [Values defined for LMP test mode commands]
 */
typedef enum
{
    SINGLE_FREQ         = 0,            /* Single Frequency Hopping */
    EUROPE_USA_FREQ     = 1,            /* Europe and the USA Frequency Hopping */
    FRANCE_FREQ         = 3,            /* French Frequency Hopping */
    REDUCED_FREQ        = 5             /* Reduced Frequency Hopping */
} t_rfSelection;        /* Select Type of Freqency Hopping */

/************************************
 *  Information to be stored here
 *
 *  Version Information
 *  Features Supported
 *  Manufacturer Id
 *  Country Code
 *  HCI Buffer Size
 *
 **********************************/

typedef struct {
    u_int16 HCI_revision;
    u_int16 comp_id;
    u_int16 lmp_subversion;
    u_int8  lmp_version;
    u_int8  HCI_version;
} t_versionInfo;



typedef struct t_bufferSize {
    u_int16  aclDataPacketLength;
    u_int8   scoDataPacketLength;
    u_int16  numAclDataPackets;
    u_int16  numScoDataPackets;
} t_bufferSize;

typedef struct
{
    u_int8  length;  /* String length */
    u_int8* p_utf_char; /* C String */
} t_string;          /* UTF String */

/*
 * Power control related
 */
typedef enum
{
    POWER_NOT_SUPPORT       = 0,
    INTERMEDIATE_POWER      = 1,
    MAX_POWER               = 2,
    MIN_POWER               = 3
} t_power_level;

typedef enum
{
    DECREMENT_POWER         = 0,
    INCREMENT_POWER         = 1,
    INCREMENT_MAX           = 2
} t_power_control;
 
/*
 * Security related
 */
#define LINK_KEY_SIZE       16
#define RANDOM_NUM_SIZE     16
#define PIN_CODE_SIZE       16
#define BYTE_BD_ADDR_SIZE   6
#define SRES_SIZE           4
#define ACO_SIZE            12
#define COF_SIZE            12
#define DH_KEY_SIZE         24
#define HASH_SIZE           16

typedef u_int8 t_encrypt_enable;
typedef u_int8 t_pin_code[PIN_CODE_SIZE];
typedef u_int8 t_link_key[LINK_KEY_SIZE];
typedef u_int8 t_rand[RANDOM_NUM_SIZE];
typedef u_int8 t_byte_bd_addr[BYTE_BD_ADDR_SIZE];
typedef u_int8 t_sres[SRES_SIZE];
typedef u_int8 t_aco[ACO_SIZE];
typedef u_int8 t_cof[COF_SIZE];
typedef u_int8 t_DH_key[DH_KEY_SIZE];
typedef u_int8 t_hash[HASH_SIZE];

/*
 * Park Related
 */
typedef t_deviceIndex t_parkDeviceIndex; /* index to a parked device */

typedef enum
{
    UNPARK_NONE,
    UNPARK_SLAVE_INIT,
    UNPARK_MASTER_INIT
} t_unpark_type;

typedef u_int8 t_ar_addr;

typedef u_int8 t_pm_addr;

typedef struct t_parkModeInfo
{
    t_slots d_access,
            t_access,
            m_access,
            n_b,
            delta_b,
            n_acc_slot,
            n_poll;

    t_ar_addr ar_addr;
} t_parkModeInfo;


typedef void (*t_SYS_Fn_Ptr)(void);

/*
 * Some useful macros associated with types
 */
#define mNum_Elements(array)             ( sizeof(array)/sizeof(array[0]) )

#endif
